

function monthSales() {
	var year = $("#year").val();
	$.ajax({
		url : base + "/report/monthSales",
		data : {"year":year},
		success : function(data) {
			console.log(data.map);
//			var data = new Array();
			var htmlStr = "<tr><th>月份</th><th>月销售总额（元）</th></tr>";
			if(data.list.length > 0) {
				for(var i = 0;i<data.list.length; i++) {
					var j = 0;
					j = i+1;
					htmlStr += "<tr><td>"+ j +"月"+"</td><td>" + data.list[i] + "</td></tr>";
//					data[i] = data.list[i];
				}
			}
			$("#monthSales").html(htmlStr);

			$(document).ready(function() {  
				   var chart = {
				      renderTo: 'container1',
				      type: 'column',
				      margin: 75,
				      options3d: {
				         enabled: true,
				         alpha: 12,
				         beta: 15,
				         depth: 50,
				         viewDistance: 25
				      }
				   };
				   var title = {
				      text: '月销售总额柱型报表'   
				   };
				   
				   
				   var plotOptions = {
				      column: {
				         depth: 25
				      }
				   };
				   var xAxis = {
					  categories: ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月']
						   };
				   var yAxis = {
						      allowDecimals: false,
						      min: 0,
						      title: {
						         text: '销售金额/元'
						      }
						   };  
				   var series= [{
					   name:'销售总额',
				      data:(function(){
				    	  var data1 = [];
				    	  for(var i = 0;i<data.list.length; i++){
				    		  data1.push(data.list[i]);
				    	  }
				    	  return data1;
				      })()
				   }];     
				      
				   var json = {};   
				   json.chart = chart; 
				   json.title = title;   
				   json.xAxis = xAxis; 
				   json.yAxis = yAxis;
				   json.series = series;
				   json.plotOptions = plotOptions;
				   var highchart = new Highcharts.Chart(json);
				  
				   function showValues() {
				      $('#R0-value').html(highchart.options.chart.options3d.alpha);
				      $('#R1-value').html(highchart.options.chart.options3d.beta);
				   }

				   // Activate the sliders
				   $('#R0').on('change', function () {
				      highchart.options.chart.options3d.alpha = this.value;
				      showValues();
				      highchart.redraw(false);
				   });
				   $('#R1').on('change', function () {
				      highchart.options.chart.options3d.beta = this.value;
				      showValues();
				      highchart.redraw(false);
				   });

				   showValues();
				});
			
			
		
		}
	});}

function saleNums(){
	var date1 = $("#date1").val();
	var date2 = $("#date2").val();
	$.ajax({
		url : base + "/report/saleNum",
		data : {"date1":date1, "date2":date2},
		success : function(data) {
			console.log(data.map);
			var htmlStr = "<tr><th>产品名称</th><th>销售量/份</th></tr>";
			var j = 0;
			if(data.list.length > 0) {
				
				for(var i = 0;i<data.list.length; i= i+2) {
					j = i+1;
					htmlStr += "<tr><td>" + data.list[i] + "</td><td>" + data.list[j] + "</td></tr>";
				}
			}
			$("#saleNums").html(htmlStr);
			
			
			$(document).ready(function() {  
				   var chart = {
				      renderTo: 'container2',
				      type: 'column',
				      margin: 75,
				      options3d: {
				         enabled: true,
				         alpha: 12,
				         beta: 15,
				         depth: 50,
				         viewDistance: 25
				      }
				   };
				   var title = {
				      text: '产品销量柱型报表'
				   };
				   
				   
				   var plotOptions = {
				      column: {
				         depth: 25
				      }
				   };
				   var xAxis = {
					  categories: (function(){
				    	  var name = [];
				    	  for(var i = 0;i<data.list.length; i= i+2){
				    		  name.push(data.list[i]);
				    	  }
				    	  return name;
				      })()
						   };
				   var yAxis = {
						      allowDecimals: false,
						      min: 0,
						      title: {
						         text: '销售数量/份'
						      }
						   };  
				   var series= [{
					   name:'销售数量',
				       data:(function(){
				    	  var datas = [];
				    	  var k = 0;
				    	  for(var i = 0;i<data.list.length; i= i+2){
				    		  k = i+1;
				    		  datas.push(data.list[k]);
				    	  }
				    	  return datas;
				      })()
				   }];     
				      
				   var json = {};   
				   json.chart = chart; 
				   json.title = title;   
				   json.xAxis = xAxis; 
				   json.yAxis = yAxis;
				   json.series = series;
				   json.plotOptions = plotOptions;
				   var highchart1 = new Highcharts.Chart(json);
				  
				   function showValues() {
					      $('#R0-value').html(highchart1.options.chart.options3d.alpha);
					      $('#R1-value').html(highchart1.options.chart.options3d.beta);
					   }

					   // Activate the sliders
					   $('#R0').on('change', function () {
					      highchart1.options.chart.options3d.alpha = this.value;
					      showValues();
					      highchart1.redraw(false);
					   });
					   $('#R1').on('change', function () {
					      highchart1.options.chart.options3d.beta = this.value;
					      showValues();
					      highchart1.redraw(false);
					   });

					   showValues();
				});
			
		}
	});
	
}

